<template>
	<view class="play-bar flex-box flex-valign" @click="openDetail">
		<view class="icon-btn flex-box flex-valign">
			<image src="/static/bg.jpg" :class="{roating: playing}"></image>
		</view>
		<view class="flex-item">
			{{musicTitle}}
		</view>
		<view class="icon-btn" @click.stop="togglePlay">
			<circle-progress :size="66" :value="progress">
				<i :class="'music-icon music-icon-' + (playing ? 'stop' : 'play')"></i>
			</circle-progress>
		</view>
		<view class="icon-btn">
			<i class="music-icon music-icon-menu"></i>
		</view>
	</view>
</template>

<script>
	import circleProgress from '@/components/circle-progress/circle-progress.vue'
	export default {
		components: {
			circleProgress
		},
		data() {
			return {
				
			}
		},
		computed: {
			musicTitle() {
				return this.$store.state.music.title; 
			},
			playing() {
				return this.$store.state.playing;
			},
			progress() {
				return this.$store.state.music.progress;
			}
		},
		methods: {
			togglePlay() {
				this.MusicPlayer.togglePlay();
			},
			openDetail() {
				uni.navigateTo({
						url: '/pages/play/play'
				});
			},
		},
		mounted() {
			const query = uni.createSelectorQuery().in(this);
			query.select('.play-bar').boundingClientRect(data => {
				this.$emit('mounted', data.height);
			}).exec();
		}
	}
</script>

<style lang="scss" scoped>
	.play-bar{
		background: #FFFFFF;
		border-top: #eee solid 1rpx;
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		.music-icon{
			font-size: 40rpx;
		}
		.music-icon-stop{
			font-size: 28rpx;
			color: $main-color;
		}
		.music-icon-play{
			font-size: 28rpx;
			color: #999;
		}
		.flex-item{
			font-size: 28rpx;
		}
		.icon-btn{
			padding: 10rpx;
			image{
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
				&.roating{
					animation: album_rotating linear 16s infinite;
				}
			}
		}
	}
	@keyframes album_rotating{
		from{
			transform: rotate(0deg);
		}
		to{
			transform: rotate(360deg);
		}
	}
</style>
